home *** CD-ROM | disk | FTP | other *** search
- /***
- * CColorPicker.c
- *
- * by Bernie Bernstein (bernard@cs.colorado.edu)
- *
- * SUPERCLASS = CPane
- *
- * pick a color when this control is clicked on.
- * display its color.
- ***/
-
- #include <Global.h>
- #include <Picker.h>
-
- #include "CColorPicker.h"
-
- /***
- * IColorPicker
- *
- * Initialize the color picker
- ***/
- void CColorPicker::IColorPicker(CView *anEnclosure, CBureaucrat *aSupervisor,
- short aWidth, short aHeight, short aHEncl, short aVEncl,
- SizingOption aHSizing, SizingOption aVSizing)
- {
- CPane::IPane(anEnclosure, aSupervisor, aWidth, aHeight, aHEncl, aVEncl,
- aHSizing, aVSizing);
-
- prompt[0] = '\0';
- SetWantsClicks( TRUE);
- }
-
-
- /***
- * IViewTemp
- *
- * Initialize the color picker from the view template resource
- ***/
- void CColorPicker::IViewTemp( CView *anEnclosure, CBureaucrat *aSupervisor,
- Ptr viewData)
- {
- inherited::IViewTemp( anEnclosure, aSupervisor, viewData);
- }
-
- /***
- * SetMessage
- *
- * Set the message to show in the color picker.
- ***/
- void CColorPicker::SetPrompt(ConstStr255Param msg)
- {
- CopyPString(msg, prompt);
- }
-
-
- /***
- * SetCurrentColor
- *
- * Set the current color.
- ***/
- void CColorPicker::SetCurrentColor(RGBColor aColor)
- {
- currentColor = aColor;
- Refresh();
- }
-
-
- /***
- * GetCurrentColor
- *
- * Get the current color
- ***/
- RGBColor CColorPicker::GetCurrentColor(void)
- {
- return currentColor;
- }
-
-
- /***
- * DoClick
- *
- * When the picker is clicked, bring up the standard color picker dialog.
- ***/
- void CColorPicker::DoClick( Point hitPt, short modifierKeys, long when)
- {
- if (gSystem.hasColorQD)
- {
- Boolean gotColor;
- Point pos;
- RGBColor newColor;
- pos.h = pos.v = 0;
- gotColor = GetColor(pos, prompt, ¤tColor, &newColor);
- if (gotColor)
- {
- SetCurrentColor(newColor);
- }
- }
- else
- {
- }
- }
-
-
- /***
- * Draw
- *
- * Draw the color
- ***/
- void CColorPicker::Draw( Rect *area)
- {
- RGBColor saveColor;
-
- if (gSystem.hasColorQD)
- {
- GetForeColor(&saveColor);
- RGBForeColor(¤tColor);
- PaintRect( area);
- RGBForeColor(&saveColor);
- }
- else
- {
- PenPat (gray);
- PenMode(patBic);
- PaintRect( area);
- PenNormal();
- }
- }
-
-
-
-
-
-